﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Moon.Sql
{
    public class OracleUpdateable<T> : UpdateableProvide<T>
    {
        public OracleUpdateable(IDatabase _Database)
            : base(_Database) { }

        public override SqlBuilderResult ToSql()
        {
            SqlBuilderResult sqlResult = GetSqlParam();
            string sql = "update {0} {3} set {1} where {2}";
            if (_Limit.HasValue)
            {
                sql += " rownum<= " + _Limit;
            }
            return new SqlBuilderResult()
            {
                Sql = string.Format(sql, IsQuote ? Database.SqlDialect.SetSqlName(MasterTableName) : MasterTableName,
                    sqlResult.Sql, _Where.Sql, CommonUtils.TableAliasName),
                DynamicParameters = sqlResult.DynamicParameters
            };
        }

        public override int BulkUpdate<TempTable>(List<TempTable> updateList)
        {
           throw new NotImplementedException();
        }
        public override async Task<int> BulkUpdateAsync<TempTable>(List<TempTable> updateList)
        {
            throw new NotImplementedException();
        }
    }
}
